package com.example.app;

import com.example.bean.Cat;
import com.example.bean.Mouse;
import com.example.config.SpringConfig4;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class App5 {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfig4.class);
//       上下文容器对象液晶初始化完毕后，手工加载bean  这样同名的类会被覆盖
        applicationContext.registerBean("tom", Cat.class,0);
        applicationContext.registerBean("tom", Cat.class,1);
        applicationContext.registerBean("tom", Cat.class,2);
        applicationContext.register(Mouse.class);
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
        System.out.println("-------------");
        System.out.println(applicationContext.getBean(Cat.class));
    }
}
